<template>
  <div class="h5-container">
    <!-- 背景 -->
    <div class="background">
      <img src="@/assets/产品.jpeg" alt="背景" />
    </div>

    <!-- 产品 -->
    <div class="products">
      <img
          src="@/assets/调味料.png"
          height="469"
          width="469"
          alt="调味料"
          @click="handleProductClick"
      />
      <img
          src="@/assets/料酒.png"
          height="668"
          width="668"
          alt="料酒"
          @click="handleProductClick"
      />
      <img
          src="@/assets/蚝油.png"
          height="700"
          width="700"
          alt="蚝油"
          @click="handleProductClick"
      />
    </div>

    <!-- 气泡提示 -->
    <div class="speech-bubble">
      <div style="text-align: center; opacity: 1">
        最后，我们全线投放市场...
      </div>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    // 添加点击事件监听器
    const products = this.$el.querySelectorAll('.products img');
    products.forEach((product) => {
      product.addEventListener('click', this.handleProductClick);
    });
  },
  methods: {
    handleProductClick() {
      alert('开始投放市场！');
    },
    toggleMenu() {
      const nav = document.getElementById('mobile-nav');
      nav.classList.toggle('active');
    }
  }
};
</script>

<style scoped>
body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: 'Arial', sans-serif;
  background-color: #f4f4f4;
  overflow: hidden;
}

.h5-container {
  position: relative;
  width: 100%;
  height: 100vh;
}

.background img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.tree-house {
  position: absolute;
  bottom: 10%;
  left: 10%;
  width: 300px;
  z-index: 2;
}

.products img {
  position: absolute;
  width: 80px;
  height: auto;
  animation: float 3s ease-in-out infinite;
  z-index: 3;
}

.products img:nth-child(1) {
  top: 20%;
  left: 20%;
  animation-delay: 0s;
}

.products img:nth-child(2) {
  top: 25%;
  left: 40%;
  animation-delay: 0.5s;
}

.products img:nth-child(3) {
  top: 15%;
  right: 20%;
  animation-delay: 1s;
}

.speech-bubble {
  position: absolute;
  bottom: 25%;
  left: 30%;
  width: 200px;
  padding: 5px;
  opacity: 0.8;
  background: white;
  border-radius: 25px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 4;
}

/* 顶部导航 */
header {
  background-color: #d00000;
  color: white;
  display: flex;
  align-items: center;
  width: auto;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  position: relative;
}

header img {
  max-height: 50px;
}

/* 导航菜单 */
nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 1rem;
}

nav a:hover {
  text-decoration: underline;
}

/* 移动端样式 */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  nav {
    display: none;
    flex-direction: column;
    background-color: #d00000;
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    padding: 1rem 0;
  }

  nav a {
    padding: 0.5rem 1rem;
  }

  nav.active {
    display: flex !important;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}
</style>
